<template>
	<view class="main">
		<view class="SearchDiv" v-if="OtherShow==true">
			<view class="uni-padding-wrap uni-common-mt">
				<uni-segmented-control :current="current" :values="items" :style-type="styleType"
					:active-color="activeColor" @clickItem="onClickItem" />
			</view>
		</view>
		<view class="SearchDiv2" v-else>
			<xweek v-on:back="changeBack"></xweek>
		</view>
		<view class="content RuKucontent" v-if="OtherShow==false">
			<view class="Lists">
				<view class="RuKuList" v-for="item in RuKuList" :key="item.id" @click="toActivityDetails(item)">

					<view class="ItemRuKuTop">
						<view class="ItemRuKuBat">
							{{user.name}}
						</view>
						<view class="ItemRuKuTime" style="color: #999999;">
							{{item.createTime}}
						</view>
					</view>
					<view class="ItemRuKuBottom" style="border-top: 2rpx solid #e9e9e9;">
						<view class="ItemRuKuBat">
							总零售价：￥{{item.totalCostPrice}}
						</view>
						<view class="ItemRuKuBat">
							入库金额：￥{{item.salePrice}}
						</view>
						<view class="ItemRuKuBat">
							入库数量：{{item.stock}}
						</view>
						<view class="ItemTopRight" style="color: #93cdba;">
							利润：{{(Number(item.salePrice) - Number(item.totalCostPrice)).toFixed(2)}}
						</view>
					</view>

				</view>
			</view>
		</view>

		<view class="content" v-else>
			<view v-if="current === 0">
				<view class="Lists">
					<view class="List" v-for="item in WeiJieShu" :key="item.activityId">
						<view class="ItemTop">
							<view class="ItemTopLeft">
								<view class="ItemTitle">
									{{ item.activityName}}
								</view>
								<view class="ItemTip">
									{{ item.type | formatRule }}
								</view>
							</view>
							<view class="ItemTopRight">
								<view class="ItemTime">
									{{item.startTime}}
									<view class="Zhi">至</view>
									{{item.endTime}}
								</view>
								<view class="ItemContent" v-if="item.type=='vip_active'">
									金额积分比：{{item.yzsActivityRuleList[0].ruleField }}
								</view>
								<view class="ItemBeiZhu">
									{{item.note}}
								</view>
							</view>
						</view>

						<view class="ItemBottom">
							<button class="YiBanBottom" @click="selectTag(item)"
								v-if="item.type=='offerCoinCoupons' || item.type=='offerFoldCoupons' || item.type=='offerMinusCoupons'">发放优惠券</button>

							<button class="YiBanBottom" @click="JieShuHuoDon(item)">结束活动</button>
							<!-- <button class="YiBanBottom" @click="AddBaoBei">添加宝贝</button> -->
							<button class="YiBanBottom" @click="TuiGuan(item)"
								v-if="item.type =='offerCoinCoupons' || item.type =='offerFoldCoupons'||item.type =='offerMinusCoupons'">推广</button>
							<button class="XiuGaiBottom" @click="ChangeHuoDon(item)">修改活动</button>
						</view>

					</view>
				</view>
			</view>
			<view v-if="current === 1">
				<view class="Lists">
					<view class="List" v-for="item in YiJieShu" :key="item.activityId">
						<view class="ItemTop">
							<view class="ItemTopLeft">
								<view class="ItemTitle">
									{{ item.activityName}}
								</view>
								<view class="ItemTip">
									{{ item.type | formatRule }}
								</view>
							</view>
							<view class="ItemTopRight">
								<view class="ItemTime">
									{{item.startTime}}
									<view class="Zhi">至</view>
									{{item.endTime}}
								</view>
								<view class="ItemContent" v-if="item.type=='vip_active'">
									金额积分比：{{item.yzsActivityRuleList[0].ruleField }}
								</view>
								<view class="ItemBeiZhu">
									{{item.note}}
								</view>
							</view>
						</view>
						<view class="ItemBottom">
							<!-- <button class="YiBanBottom" @click="JieShuHuoDon(item)">结束活动</button> -->
							<!-- 							<button class="YiBanBottom" @click="AddBaoBei">添加宝贝</button>
							<button class="YiBanBottom" @click="ChangeBaoBei">修改宝贝</button> -->
							<button class="XiuGaiBottom" @click="ChangeHuoDon(item)">修改活动</button>
						</view>
					</view>
				</view>

			</view>
		</view>
		<uni-popup ref="share" type="share" safeArea backgroundColor="#fff">
			<uni-popup-share title="促销活动" @select="select"></uni-popup-share>
		</uni-popup>
		<uni-popup ref="share1" type="share" safeArea backgroundColor="#fff">
			<uni-popup-TuiGaun title="推广优惠券" @select="select1"> </uni-popup-TuiGaun>
		</uni-popup>

		<kevyempty :show="true" type="goods" text="这里空空如也~" v-if="OtherShow==false && RuKuList.length==0"></kevyempty>
		<kevyempty :show="true" type="goods" text="这里空空如也~" v-if="OtherShow==true && WeiJieShu.length==0"></kevyempty>

		<uni-popup ref="popup1" background-color="#fff" @change="change">
			<view class="PopDiv">
				<view class="PopTitle">
					新建活动类型
				</view>
				<view :class="PopActive == index?'PopItem PopActive':'PopItem'" v-for="(item,index) in Pop1List"
					@click="ChangePop1(item,index)" :key="item.id">
					{{item.name}}
				</view>
				<view class="PopButtonDiv">
					<view class="PopButton" style="border-right: 2rpx solid #e4e6e5;" @click="Pop1Cancel">
						取消
					</view>
					<view class="PopButton" @click="Pop1QueDing">
						确定
					</view>
				</view>
			</view>

		</uni-popup>
		<uni-popup ref="popup4" background-color="#fff" @change="change">
			<view class="PopDiv">
				<view class="PopTitle">
					发放优惠券方式
				</view>
				<view :class="PopActive == index?'PopItem PopActive':'PopItem'" v-for="(item,index) in Pop2List"
					@click="ChangePop1(item,index)" :key="item.id">
					{{item.name}}
				</view>
				<view class="PopButtonDiv">
					<view class="PopButton" style="border-right: 2rpx solid #e4e6e5;" @click="Pop2Cancel">
						取消
					</view>
					<view class="PopButton" @click="Pop2QueDing">
						确定
					</view>
				</view>
			</view>
		</uni-popup>

		<uni-fab ref="fab" :popMenu="false" @fabClick="fabClick" horizontal="right"  />

<!-- 		<uni-fab ref="fab" :popMenu="true" horizontal="right" :content="content" :pattern="pattern" @trigger="trigger"
			/> -->


		<uni-popup ref="popup3" type="bottom" class="page-red-envelope">

			<view class="GuanZhu">
				<view class="GuanZhuTitle">长按保存</view>

				<image :src="userPhoto" mode="" class="GuanZhuEWM" :show-menu-by-longpress="true"></image>
			</view>
		</uni-popup>



		<view>
			<!-- 普通弹窗 -->
			<uni-popup ref="popup2" background-color="#fff" type="bottom">

				<view class="PopIndex3">
					<view class="ItemTitle">
						上传入库订单（仅支持excel文件）
					</view>

					<view class="ItemDiv SaoMiaoDiv">

						<view class="shancuanMoBan">
							<uni-file-picker limit="1" file-mediatype="all" @select="shancuanMoBan"></uni-file-picker>
						</view>
					</view>
					<view class="ShanChuanTip">
						（请核对好文件的列名，确保与上传模板的列名保持一致）
					</view>
					<view class="DownLoadMoBan">
						<button class="DownLoadMoBanbutton" @click="DownLoadMoBan($api.InboundModel)">下载上传模板</button>
					</view>

				</view>
			</uni-popup>
		</view>
		<view class="">
			<uni-popup ref="Tagpopup" background-color="#fff" type="bottom">
				<view class="PopTagDiv">
					<view class="PopButton" style="border-right: 2rpx solid #e4e6e5;" @click="TagPopCancel">
						取消
					</view>
					<view class="PopButton" @click="SentHuoDon">
						确定
					</view>
				</view>
				<view class="TagPopDiv">
					<view class="PopTitle">
						请选择标签
					</view>
					<view class="selectTag">
						<!-- <uni-data-select v-model="SelectTag" :localdata="SelectNoJoinList" @change="change"></uni-data-select> -->
						<radio-group @change="radioChange">
							<label v-for="(item, index) in SelectNoJoinList" class="radiobox" :key="item.value">
								<view>
									<radio :value="item.value" :checked="index === current" class="radio"
										color="#007aff" />
								</view>
								<view class="radioname">{{item.name}}</view>
							</label>
						</radio-group>
					</view>
				</view>
			</uni-popup>
		</view>
	</view>
</template>
 
<script>
	import kevyempty from '@/components/kevy-empty/kevy-empty.vue'
	import xweek from '@/components/junkj-xweek/xweek.vue'
	import uniCopy from '@/common/uni-copy.js'
	import {
		pathToBase64,
		base64ToPath
	} from '@/common/image-tool.js'
	import getDateTime from '../index/getdateTime.js';
	export default {
		components: {
			kevyempty,
			xweek
		},
		data() {
			return {
				Pop2List: [],
				// 标签列表
				MarkList: [],
				activityId: '',
				SelectTag: '',
				SelectNoJoinList: [],
				userPhoto: null,
				pattern: {
					color: '#7A7E83',
					selectedColor: '#007AFF',
					buttonColor: '#007AFF',
					backgroundColor: '#fff',
					selectedColor: '#007AFF',
					buttonColor: '#007AFF',
					iconColor: '#fff'
				},
				YiJieShu: [],
				content: [{
						iconPath: '/static/icons/PiLiangDaoRu.png',
						text: '批量导入',
						active: false
					},
					{
						iconPath: '/static/icons/daochu.png',
						text: '导出订单',
						active: false
					},
					{
						iconPath: '/static/icons/AddShop.png',
						text: '添加订单',
						active: false
					},
				],
				user: {},
				RuKuList: [],
				PopActive: 0,
				Pop1List: [],
				PopList: [{
						name: '不限购',
						id: 1
					},
					{
						name: '首件优惠',
						id: 2
					},
					{
						name: '限购',
						id: 3
					}
				],
				colorIndex: 0,
				activeColor: 'rgba(54, 152, 252, 1)',
				current: 0,
				styleType: 'text',
				items: ['未结束活动', '已结束活动'],
				searchValue: '',
				WeiJieShu: [],
				PageData: {
					pageNum: 1,
					pageSize: 10
				},
				count: 0,

				OtherShow: true,
				ToDay: "",

			}
		},
		mounted() {
			// this.queryGoodsByBarcode("test2(该字段不能重复)")
		},
		onReachBottom() { // 下拉加载
			let allTotal = this.PageData.pageNum * this.PageData.pageSize;
			if (allTotal < this.count) {

				this.PageData.pageNum++;
				this.businessgoodslist(0)
			} else {

			}
		},
		filters: {
			formatRule(val) {
				let a = ''
				if (val == 'vip_active') {
					a = '会员活动'
				}
				if (val == 'specialActivity') {
					a = '特价活动'
				}
				if (val == 'discount') {
					a = '折扣活动'
				}
				if (val == 'offerCoinCoupons') {
					a = '兑换券'
				}
				if (val == 'offerFoldCoupons') {
					a = '折扣券'
				}
				if (val == 'offerMinusCoupons') {
					a = '满减券'
				}
				if (val == 'FullMinusActivity') {
					a = '满减活动'
				}
				if (val == 'fullFoldActivity') {
					a = '满折活动'
				}
				if (val == 'BuyActivity') {
					a = '第n件促销'
				}
				return a
			}
		},
		onLoad(option) {
			uni.getStorageSync("MenDianList").forEach(item => {
				let selectMenDian = uni.getStorageSync("storeId")
				if (item.id == selectMenDian) {
					this.user = item
				}
			})

			if (option.type == "RuKu") {
				this.OtherShow = false
				let time = getDateTime.getDateStr(null, 0)
				this.ToDay = time.y + "-" + time.m + "-" + time.d
				this.businessgoodslist(1)
				uni.setNavigationBarTitle({
					title: '入库订单列表'
				});
			} else {
				this.ActiveList()
				this.ActivityJSlist()
			}
		},
		onShow() {
			this.getAllTags()
		},
		methods: {
			radioChange(e) {
				console.log(e.detail.value);
				console.log(e);
				this.SelectTag = e.detail.value;
			},
			TagPopCancel() {
				this.$refs.Tagpopup.close('bottom')
			},
			getAllTags() {
				let url = this.$api.GetAllTags;
				this.$request(url, null, "GET", false).then(res => {
					if (res.code == '0') {
						console.log('查看成功', res);
						res.data.forEach(item => {
							this.SelectNoJoinList.push({
								name: item.name,
								value: item.tagId
							})
						});
					} else {
						uni.showToast({
							title: res.description,
							icon: 'none'
						});
					}
				})
			},

			selectTag(item) {
				console.log(item);
				this.activityId = item.activityId;
				this.Pop2List = [{
						name: '选择标签发放',
						id: 1,
						type: "specialActivity"
					},
					{
						name: '选择会员发放',
						id: 2,
						type: "discount"
					},
				
				]
				
				this.$refs.popup4.open()
				

			},
			// 发放优惠券
			SentHuoDon() {
				let url = this.$api.SentHuoDong + '?activityId=' + this.activityId + '&tagId=' + this.SelectTag;
				this.$request(url, null, "GET", false).then(res => {
					if (res.code == '0') {
						console.log('发放优惠券成功', res);
						uni.$showMsg('发放成功!');
						this.$refs.Tagpopup.close()
					} else {
						uni.showToast({
							title: res.description,
							icon: 'none'
						});
					}
				})
			},
			TuiGuan(item) {
				this.$refs.share1.open()
			},
			trigger(e) {
				console.log(e)
				if (e.index == 2) {
					this.fabClick()
				} else if (e.index == 1) {
					uni.showModal({
						title: "导出门店商品库",
						content: "是否确认导出门店商品库",
						success: (res) => {
							uni.showLoading({
								title: '正在导出中'
							});
							//下载文件
							let store = wx.getStorageSync("storeId") // 从缓存获取当前选择门店
							let url = this.$api.businessgoodsExport + "?create_time=" + this
								.ToDay //下载地址，后端接口获取的链接
							this.DownLoadMoBan(url)
						},
						fail() {

						}
					})
				} else {
					this.$refs.popup2.open('bottom')
				}
			},
			DownLoadMoBan(url) {

				let that = this
				uni.showLoading({
					title: "加载中"
				})
				uni.downloadFile({
					header: {
						// 'uid': userId,
						'token': uni.getStorageSync("token")
					},
					url: url, //下载地址，后端接口获取的链接
					success: (data) => {
						uni.hideLoading()
						if (data.statusCode === 200) {
							uni.saveFile({ //文件保存到本地
								tempFilePath: data.tempFilePath, //临时路径
								success: function(res) {
									uni.showToast({
										icon: 'none',
										mask: true,
										title: '文件已保存!',
										duration: 3000,
									});
									uni.openDocument({
										//fileType: 'docx',
										showMenu: true, //关键点,可以转发到微信
										filePath: res.savedFilePath,
										success: function(res) {
											console.log('打开文档成功');
										}
									});
								}
							});
						}
					},
					fail: (err) => {
						uni.hideLoading()
						console.log(err);
						uni.showToast({
							icon: 'none',
							mask: true,
							title: '失败请重新下载',
						});
					},
				});

			},

			changeBack: function(d) {
				console.log(d);
				this.ToDay = d
				this.businessgoodslist(1)
			},
			ActiveList() {
				console.log(2222)
				let url = this.$api.Activitylist + '?storeId=' + uni.getStorageSync("storeId")
				this.$request(url, null, "GET", false).then(res => {
					if (res.code == '0') {
						this.WeiJieShu = res.data.data
					}
				})
			},
			ActivityJSlist() {
				let url = this.$api.ActivityJSlist + '?storeId=' + uni.getStorageSync("storeId")
				this.$request(url, null, "GET", false).then(res => {
					if (res.code == '0') {
						this.YiJieShu = res.data.data
					}
				})
			},
			businessgoodslist(type) {

				console.log(this.ToDay);
				let url = this.$api.businessgoodslist + '?pageNum=' + this.PageData.pageNum + '&pageSize=' + this.PageData
					.pageSize + '&create_time=' + this.ToDay
				this.$request(url, null, "GET", false).then(res => {
					if (res.code == '0') {
						if (type == 1) {
							this.RuKuList = res.data.data
							this.count = res.data.count
						} else {
							res.data.data.forEach(item => {
								this.RuKuList.push(item)
							})

						}

					}
				})
			},

			toActivityDetails(item) {
				if (this.OtherShow == false) {
					uni.navigateTo({
						url: "/pages/promotion/ActivityDetails?type=RuKu&id=" + item.id,
					})
				}
			},
			ChangePop1(item, index) {
				this.PopActive = index
			},
			JieShuHuoDon(item) {
				let this_ = this
				uni.showModal({
					title: '结束活动',
					content: '结束后宝贝将失去此优惠',
					success: (res) => {
						if (res.confirm) {
							uni.showLoading({
								title: "加载中"
							})
							let url = this_.$api.Activitydel + '/' + item.activityId
							this_.$request(url, null, "GET", false).then(res => {
								uni.hideLoading()
								if (res.code == '200') {
									uni.showToast({
										title: "删除成功！",
										icon: 'success'
									});
									this.ActiveList()
									this.ActivityJSlist()

								} else {
									uni.showToast({
										title: "删除失败",
										icon: 'fail'
									});
								}
							})
							console.log('用户点击确定');

						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			AddBaoBei() {
				uni.navigateTo({
					url: "/pages/promotion/NextBuZhou/NextBuZhou",
				})
			},
			ChangeBaoBei() {
				uni.navigateTo({
					url: "/pages/promotion/NextBuZhou/NextBuZhou",
				})
			},
			Pop1Cancel() {
				this.PopActive = 0
				this.$refs.popup4.close()
			},
			Pop2Cancel() {
				this.PopActive = 0
				this.$refs.popup4.close()
			},
			Pop1QueDing() {
				console.log(4444)
				let TipName = ''
				let id = ''
				let type = ''
				this.Pop1List.forEach((item, index) => {
					if (this.PopActive == index) {
						TipName = item.name
						id = item.id
						type = item.type
					}
				})
				uni.navigateTo({
					url: "/subpkg/promition/Details?name=" + type + '&TipName=' + TipName + '&id=' + id,
				})
				// uni.navigateTo({
				// 	url:'/subpkg/Login/Login'
				// })
				this.$refs.popup1.close()

				this.PopActive = 0
			},
			Pop2QueDing() {
				if (this.PopActive == 0) {
					this.$refs.Tagpopup.open();
					return;
				}

				uni.navigateTo({
					url: "/pages/vip/operation" + '?activityId=' + this.activityId +"&radioflag2=true",
				})
				this.$refs.popup4.close()
				this.PopActive = 0
			},
			ChangeHuoDon(item) {
				uni.navigateTo({
					url: "/subpkg/promition/Details?type=edit&id=" + item.activityId + "&TipName=" + this
						.formatRule1(item.type) + "&name=" + item.type
				})
			},
			select1(item, index) {
				let url;
				switch (item.item.name) {
					case 'xianshi':
						let str;
						if (this.$api.OurUpLoadUrl == 'https://jkht.wteam.club') {
							str = this.$api.OurUpLoadUrl + "/file/file/?storeId=" + uni.getStorageSync("storeId")
						} else {
							str = this.$api.OurUpLoadUrl + "/file/ToVipCode/?storeId=" + uni.getStorageSync(
								"storeId")
						}

						url = this.$api.getEWM + "?content=" + str
						break;
					case 'shoujian':
						url = this.$api.Getwxacode + "?storeId=" + uni.getStorageSync("storeId")
						break;

					case 'manjian':

						url = this.$api.GetgenerateUrllink + "?storeId=" + uni.getStorageSync("storeId")

						break;

				}
				uni.showLoading({
					content: "加载中"
				})
				if (item.item.name == 'xianshi') {
					uni.request({
						url: url, //url地址
						method: 'GET',
						responseType: 'arraybuffer',
						header: {
							'Content-Type': 'application/json',
						},
						success: res => {
							uni.hideLoading()
							if (item.item.name == 'xianshi') {
								const arrayBuffer = new Uint8Array(res.data)
								const base64 = "data:image/png;base64," + uni.arrayBufferToBase64(
									arrayBuffer) //这里需要添加前缀
								this.userPhoto = base64 || ''
								this.$refs.popup3.open()
							} else {

							}
						}
					})

				} else {


					this.$request(url, null, "GET", false).then(res => {
						uni.hideLoading()
						if (item.item.name == 'manjian') {
							uniCopy({
								content: res.data,
								success: (res) => {
									uni.showToast({
										title: res,
										icon: 'none'
									})
								},
								error: (e) => {
									uni.showToast({
										title: e,
										icon: 'none',
										duration: 3000,
									})
								}
							})
						} else {
							/// 获取到base64Data
							var base64Data = res.data;
							/// 通过微信小程序自带方法将base64转为二进制去除特殊符号，再转回base64
							base64Data = wx.arrayBufferToBase64(wx.base64ToArrayBuffer(base64Data));
							/// 拼接请求头，data格式可以为image/png或者image/jpeg等，看需求
							const base64ImgUrl = "data:image/png;base64," + base64Data;
							/// 得到的base64ImgUrl直接给图片:src使用即可
							this.userPhoto = base64ImgUrl
							this.$refs.popup3.open()
						}

					})
				}


			},
			base64ToSave(base64data, FILE_BASE_NAME = 'tmp_base64src') {
				const fsm = uni.getFileSystemManager();
				return new Promise((resolve, reject) => {
					//format这个跟base64数据的开头对应
					const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/
					.exec(base64data) || [];
					if (!format) {
						reject(new Error('ERROR_BASE64SRC_PARSE'));
					}
					const filePath =
						`${wx.env.USER_DATA_PATH}/${FILE_BASE_NAME}.${format}`;
					const buffer = wx.base64ToArrayBuffer(bodyData);
					fsm.writeFile({
						filePath,
						data: buffer,
						encoding: 'binary',
						success() {
							resolve(filePath);

						},
						fail() {
							reject(new Error('ERROR_BASE64SRC_WRITE'));
						},
					});
				});
			},
			select(item, index) {
				switch (item.item.name) {
					case 'xianshi':
						this.Pop1List = [{
								name: '特价活动',
								id: 1,
								type: "specialActivity"
							},
							{
								name: '折扣活动',
								id: 2,
								type: "discount"
							},

						]
						this.$refs.popup1.open()
						break;
					case 'shoujian':
						this.Pop1List = [{
								name: '满减券',
								id: 1,
								type: "offerMinusCoupons"
							},
							{
								name: '折扣券',
								type: "offerFoldCoupons",
								id: 2
							},
							{
								name: '兑换券',
								id: 3,
								type: "offerCoinCoupons"
							},
						]
						this.$refs.popup1.open()
						// uni.navigateTo({
						// 	url: "/pages/promotion/Details?name=" + 'shoujian',
						// })
						break;
					case 'manjian':
						this.Pop1List = [{
								name: '满N元减/送',
								id: 1,
								type: "FullMinusActivity"
							},
							{
								name: '满N件减/送',
								id: 2,
								type: "FullMinusActivity"
							},
							{
								name: '满N元折/送',
								id: 3,
								type: "fullFoldActivity"
							},
							{
								name: '满N件折/送',
								id: 4,
								type: "fullFoldActivity"
							},
						]
						this.$refs.popup1.open()
						// uni.navigateTo({
						// 	url: "/pages/promotion/Details?name=" + 'manjian',
						// })
						break;
					case 'dierjian':
						this.Pop1List = [{
								name: '第二件半价',
								id: 1,
								type: "BuyActivity"
							},
							{
								name: '买一送一',
								id: 2,
								type: "BuyActivity"
							},
							{
								name: '自定义优惠',
								id: 3,
								type: "BuyActivity"
							},

						]
						this.$refs.popup1.open()
						// uni.navigateTo({
						// 	url: "/pages/promotion/Details?name=" + 'dierjian',
						// })
						break;
					case 'vipactive':
						uni.navigateTo({
							url: "/pages/promotion/Details?name=vip_active&TipName=会员活动&id=13",
						})
						break;
				}
			},
			fabClick() {

				if (!this.OtherShow) {
					uni.navigateTo({
						url: "/pages/promotion/Details?type=RuKu",
					})
				} else {
					this.$refs.share.open()
				}

			},
			input(res) {
				console.log(res)
				let _this = this

				this.Searchquery.name = res.value
				this.platformGoodsQuery(1)
			},
			NextBuZhou() {
				uni.navigateTo({
					url: "/pages/promotion/NextBuZhou/SheZhiZheKou",
				})
			},
			change(e) {
				if (e.show == false) {
					this.PopActive = 0
				}
			},
			// change(e) {
			// 	console.log("e:", e);
			// 	this.value = e
			// 	this.Searchquery.typeId = e
			// 	this.platformGoodsQuery(1)
			// },
			goodsTypeQuery() { // 类别
				this.$request(this.$api.goodsTypeQuery, null, "POST", false).then(res => {
					if (res.code == '0') {
						let b = {
							"value": '',
							"text": '所有'
						}
						this.range.push(b)
						res.data.forEach(i => {
							let a = {
								"value": i.id,
								"text": i.name
							}
							this.range.push(a)
						})

					} else {
						uni.showToast({
							title: "错误",
							icon: 'error'
						});
					}
				})
			},
			onClickItem(e) { // 切换
				if (this.current != e.currentIndex) {
					this.current = e.currentIndex;
				}
			},
			platformGoodsQuery(num = 1) { // 商家商品
				let a = {
					storeId: this.storeId,
					name: this.searchValue,
					typeId: this.value
				}
				uni.showLoading({
					title: '加载中'
				});
				this.$request(this.$api.storeGoodsQuery, a, "POST", false).then(res => {
					uni.hideLoading();
					console.log(res)
					if (res.code == '0') {
						if (num == 1) { // 更新
							this.ShanPinList = []
							this.ShanPinList = res.data

						}
						if (num == 2) { // push
							res.data.forEach(i => {
								this.ShanPinList.push(i)
							});
						}
					} else {
						uni.showToast({
							title: "错误",
							icon: 'error'
						});
					}
				})
			},
			clear() {
				this.Searchquery.name = ''
				// this.platformGoodsQuery(1)
			},
			formatRule1(val) {
				let a = ''
				if (val == 'vip_active') {
					a = '会员活动'
				}
				return a
			},

			shancuanMoBan(e) {
				uni.showLoading({
					title: '上传中'
				});
				const tempFilePaths = e.tempFilePaths; //e是获取的图片源
				let name = encodeURIComponent(JSON.parse(uni.getStorageSync("user")).name)
				uni.uploadFile({
					url: this.$api.OurUpLoadUrl + '/common/upload/SGoodsexcel', //上传图片的后端接口
					// url: 'https://admin.51sioc.com/common/upload/SGoodsexcel', //上传图片的后端接口
					// url: 'https://jkht.wteam.club/common/upload/SGoodsexcel', //上传图片的后端接口
					// url: 'http://localhost:4003/common/upload/SGoodsexcel', //上传图片的后端接口
					filePath: tempFilePaths[0],
					name: 'file',
					header: {
						"Content-Type": "multipart/form-data",
						"userName": name
					},
					responseType: "arraybuffer", //特别注意的是此处是请求文件流必须加上的属性，不然你导出到手机上的时候打不开，即使是打开了也是空白

					success: res1 => {
						uni.hideLoading();
						uni.showLoading({
							title: "上传成功！正在打开未上传商品...",
						});
						let url = 'file/' + JSON.parse(res1.data).urls.slice(0, -1)
						this.DownLoadMoBan(url)
						// 	},
						// })
						// this.SaveFile(res1)
						console.log(res1);
					},
					fail() {
						uni.hideLoading();
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.selectTag {
		width: 440rpx;
		height: 385rpx;
		overflow-y: auto;

		// display: flex;
		// justify-content: start;
		// align-items: center;
		.radiobox {
			display: flex;
			justify-content: start;
			margin: 35rpx;
			// width: 390rpx;

			.radioname {
				margin-left: 50rpx;
			}
		}
	}

	.PopTagDiv {
		display: flex;
		justify-content: space-around;
		align-items: center;

	}

	.TagPopDiv {
		height: 500rpx;
		width: 100%;
		padding: 10rpx;
		background-color: #fff;
		display: flex;
		flex-direction: column;
		// justify-content: center;
		align-items: center;
		font-size: 30rpx;
	}

	.PopItem {
		height: 95rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		width: 100%;
		/* border-bottom: 4rpx solid #f0f0f0; */
		font-size: 32rpx;
		background-color: #e4e5e7;
		width: 54vw;
		border-radius: 20vw;
		margin-bottom: 25rpx;
	}

	.PopCancel {
		height: 90rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		width: 100%;
		border-top: 14rpx solid #f0f0f0;
		font-size: 31rpx;
	}

	.GuanZhu {
		background: white;
		display: flex;
		flex-direction: column;
		align-items: center;
		padding-bottom: 50rpx;
	}

	.GuanZhuEWM {
		width: 600rpx;
		height: 600rpx;
		z-index: 9;
		padding: 10rpx;
		background: white;
		border: 20rpx;
	}

	.GuanZhuTitle {
		font-size: 50rpx;
		letter-spacing: 8rpx;
		margin-top: 20rpx;
		margin-bottom: 30rpx;
		z-index: 9;
	}

	.TCbacc {
		height: 0;
		position: absolute;
	}

	.TCImage {
		width: 100vw;
		height: 635rpx;
	}



	.PopIndex3 {
		padding: 50rpx 0;
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: 20rpx;

		.shancuanMoBan {
			button {
				height: 64rpx !important;
				/* line-height: 100%; */
				padding: 0;
				width: 165rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				margin: 0;
				z-index: 9999;
				text-align: center;
			}

			.uni-file-picker__lists {
				position: absolute !important;
				margin-top: 33px;
				overflow: hidden;
				background: white;
				/* min-width: 277rpx; */
				right: 21rpx;
			}
		}

		/deep/ .files-button {

			button {
				width: 250rpx !important;
				height: 70rpx !important;
				display: flex !important;
				align-items: center;
				justify-content: center;
				background: #1f64ff !important;
			}
		}

		.ItemDiv {
			display: flex;
			align-items: center;
			margin-bottom: 50rpx;
			font-size: 0.9rem;
			text-align: left;
			height: 80rpx;
		}

		.DownLoadMoBan {
			margin-right: 95rpx;
			display: flex;
			justify-content: flex-end;
			width: 100%;



			.DownLoadMoBanbutton {
				margin-right: 26rpx;
				height: 59rpx;
				width: 220rpx;
				font-size: 24rpx;
				display: flex;
				justify-content: center;
				align-items: center;
			}
		}

		.SaoMiaoDiv {

			justify-content: space-between;
		}

		.ItemTitle {
			margin-bottom: 30rpx;
			font-size: 32rpx;
			font-weight: 700;

			display: flex;
			align-items: center;
		}
	}





	.ItemRuKuTop {
		display: flex;
		align-items: center;
		justify-content: space-between;
		position: relative;
		top: 10rpx;
		font-size: 29rpx;
		padding-right: 20rpx;
		height: 100rpx;

		.ItemRuKuBat {
			margin-left: 18rpx;
			font-weight: 700;
		}


	}

	.ItemRuKuBottom {
		display: flex;
		flex-wrap: wrap;
		gap: 29rpx;
		justify-content: space-between;
		min-height: 108rpx;
		padding: 0 22rpx;

		.ItemRuKuBat {
			font-size: 28rpx;
			width: 33%;
			margin-top: 25rpx;
		}

		.ItemTopRight {
			margin-bottom: 0 !important;
			margin-top: 25rpx;
			margin-right: 0 !important;
			font-size: 28rpx;
			height: 66rpx !important;
		}
	}

	.RuKucontent {
		margin-top: 140rpx;
	}

	.RuKuList {
		border-radius: 22rpx;
		width: 97%;
		justify-content: space-around;
		display: flex;
		flex-direction: column;
		background: white;
		margin-bottom: 20rpx;
		min-height: 229rpx;
	}

	.Lists {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.SearchDiv2 {
		position: fixed;
		top: 0;
		width: 100%;
		background: white;
		z-index: 6;
	}

	.SearchDiv1 {
		display: flex;
		align-items: center;
		justify-content: space-between;
		position: fixed;
		top: 0;
		width: 100%;
		background: white;
		z-index: 6;
		height: 9vh;

		.uni-select {
			border: 0 !important;
			padding: 0 10rpx !important;
		}

		/* INPUT START */
		.uni-searchbar__box-search-input {
			height: 60rpx;
			text-indent: 0;
			color: rgba(128, 128, 128, 1);
			font-size: 24rpx !important;
		}

		.uni-searchbar__box-search-input::placeholder {
			text-align: left !important;
			font-size: 24rpx !important;
		}

		.uni-icons {
			font-size: 34rpx !important;
		}

		.uni-searchbar__box {
			height: 68rpx !important;
			border-radius: 30rpx !important;
			background-color: rgba(242, 242, 242, 1) !important;
			display: flex !important;
			justify-content: flex-start !important;
		}

		/* INPUT END */
	}

	.PopButton {
		width: 50%;
		text-align: center;
		height: 60rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-weight: 600;
		font-size: 30rpx;
	}

	.PopTitle {
		margin-bottom: 32rpx;
		font-size: 34rpx;
		font-weight: 600;
	}

	.PopButtonDiv {
		width: 100%;
		height: 100rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-top: 2rpx solid #e4e6e5;
		margin-top: 20rpx;
	}

	.PopDiv {
		width: 86vw;
		background-color: #fff;
		min-height: 30vh;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		border-radius: 11rpx;
		padding-top: 56rpx;
	}

	.PopItem {
		height: 95rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		width: 100%;
		/* border-bottom: 4rpx solid #f0f0f0; */
		font-size: 32rpx;
		background-color: #e4e5e7;
		width: 54vw;
		border-radius: 20vw;
		margin-bottom: 25rpx;
	}

	.PopActive {
		background: #197afd !important;
		color: white !important;
	}

	.PopCancel {
		height: 90rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		width: 100%;
		border-top: 14rpx solid #f0f0f0;
		font-size: 31rpx;
	}

	.content {
		padding-top: 110rpx;
	}

	.ItemBottom {
		display: flex;
		align-items: center;
		justify-content: flex-end;
		gap: 29rpx;
		padding: 0 20rpx;
	}

	.ItemTopLeft {
		margin-left: 28rpx;
		margin-bottom: 59rpx;
		height: 200rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.ItemTopRight {
		margin-right: 33rpx;
		margin-bottom: 15rpx;
		width: 450rpx;
		height: 316rpx;
	}

	.YiBanBottom {
		width: 161rpx;
		border-radius: 5vw;
		border: 2rpx solid #dcdcdc;
		color: black !important;
		height: 57rpx;
		font-size: 22rpx;
		margin: 0;
		padding: 0;
		margin-top: 20rpx;
		background: none !important;
	}

	.ItemTitle {
		font-size: 32rpx;
		font-weight: 600;
	}

	.ItemContent {
		color: #999999;
		margin-bottom: 10rpx;
	}

	.ItemBeiZhu {
		color: #999999;
	}

	.ItemTip {
		margin-top: 10rpx;
		font-size: 22rpx;
		background: #fef5eb;
		color: #ae7c3d;
		display: flex;
		align-items: center;
		justify-content: center;
		height: 42rpx;
		width: 120rpx;
	}

	.ItemTime {
		display: flex;
		align-items: center;
		font-size: 30rpx;
		height: 83rpx;
		position: relative;
		bottom: 10rpx;
		border-bottom: 2rpx solid #e9e9e9;
	}

	.Zhi {
		color: #cbcbcb;
		font-size: 27rpx;
		margin: 0 20rpx;
	}

	.XiuGaiBottom {
		width: 161rpx;
		border-radius: 5vw;
		border: 2rpx solid #b0585a;
		color: #b0585a !important;
		height: 57rpx;
		font-size: 22rpx;
		margin: 0;
		padding: 0;
		margin-top: 20rpx;
		background: none !important;
	}

	.ItemTop {
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 300rpx;
	}

	.List {
		display: flex;
		flex-direction: column;
		justify-content: center;
		background: white;
		margin-bottom: 20rpx;
		height: 350rpx;
		width: 97%;
		padding: 5% 0;
	}

	.SearchDiv {
		display: flex;
		flex-direction: column;
		justify-content: center;
		position: fixed;
		top: 0;
		width: 100%;
		background: white;
		z-index: 6;
	}

	.uni-fab__content--other-platform {
		// background-color: rgba(33, 150, 243, 1) !important;
		box-shadow: 0rpx 12rpx 10rpx 0rpx rgba(0, 0, 0, 0.5) !important;
		bottom: 140rpx !important;
	}

	.uni-fab {
		bottom: 140rpx !important;
	}

	.vue-ref:last-of-type {
		/* 		border-top-left-radius: 5vw;
		border-top-right-radius: 5vw; */
	}

	.uni-popup__wrapper {
		background: none !important;
		border-top-left-radius: 5vw;
		border-top-right-radius: 5vw;
	}

	.main {
		min-height: 100vh;
		background: #f3f3f5;
	}
</style>